package com.mszlu.blog.handler;

import com.mszlu.blog.vo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: Jiang Yizhi
 * @Date: 2022/3/27 10:45 AM
 */
/** 对加了@Controller注解的方法进行拦截处理 AOP的实现 */
@ControllerAdvice
public class AllExceptionHandler {
    /** 进行异常处理，处理Exception.class的异常 */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result doException(Exception e) {
        e.printStackTrace();
        return Result.failure(-999, "系统异常");
    }
}
